package pacman.entries.pacman.ml.destination_features;

import pacman.game.Game;
import pacman.game.Constants.DM;
import pacman.game.Constants.GHOST;

public class ThreatFromGhostsDestinationFeature extends DestinationFeature {

	@Override
	public float EvaluateDestination(Game game, int destIndex) {
		
		float threatSum = 0;

		threatSum += ThreatFromGhost(game, GHOST.BLINKY);
		threatSum += ThreatFromGhost(game, GHOST.INKY);
		threatSum += ThreatFromGhost(game, GHOST.PINKY);
		threatSum += ThreatFromGhost(game, GHOST.SUE);
		
		return threatSum/4.0f;
	}

	private float ThreatFromGhost(Game game, GHOST ghost) {
		
		double distance = game.getDistance(game.getGhostCurrentNodeIndex(ghost), 
				game.getPacmanCurrentNodeIndex(), 
				game.getGhostLastMoveMade(ghost), DM.PATH);
		
		return DestinationFeature.FeatureDistance(distance);
	}
}
